package com.c2soft.nepalcmx.controller;

import java.text.ParseException;
import java.util.List;



import lombok.extern.log4j.Log4j2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.c2soft.nepalcmx.command.NetPositionCommand;

import com.c2soft.nepalcmx.services.NetPositionService;


@Log4j2
@Controller
public class NetPositionController {
	
	@Autowired
	private NetPositionService netPositionService;
	
	
	@RequestMapping(value = "/netPosition",method=RequestMethod.GET, headers = "Accept=application/json")
	
	public @ResponseBody List<NetPositionCommand> getTrades(@RequestParam("userId") String userId,@RequestParam("ptype") String ptype)
	{
	if(ptype.equals("BOTH")){
			List<NetPositionCommand> netPosition=netPositionService.getNetPositions(userId);
			return netPosition;
		}
		else{
		List<NetPositionCommand> netPosition=netPositionService.getNetPosition(userId,ptype);
		return netPosition;
		}
		
	}
	
@RequestMapping(value = "/netPosition1",method=RequestMethod.GET, headers = "Accept=application/json")
	
	public @ResponseBody List<NetPositionCommand> getTrades1(@RequestParam("brokeId") String brokeId,@RequestParam("ptype") String ptype)
	{
	if(ptype.equals("BOTH")){
			List<NetPositionCommand> netPosition=netPositionService.getNetPositions1(brokeId);
			return netPosition;
		}
		else{
		List<NetPositionCommand> netPosition=netPositionService.getNetPosition1(brokeId,ptype);
		return netPosition;
		}
		
	}

@RequestMapping(value = "/netPosition2",method=RequestMethod.GET, headers = "Accept=application/json")

public @ResponseBody List<NetPositionCommand> getTrades2(@RequestParam("ptype") String ptype)
{
	if(ptype.equals("BOTH")){
		List<NetPositionCommand> netPosition=netPositionService.getNetPositions2();
		return netPosition;
	}
	else{
	List<NetPositionCommand> netPosition=netPositionService.getNetPosition2(ptype);
	return netPosition;
	}
	
}
	


}
